﻿using System;

namespace StudentImplementation
{
    public class Student : ICloneable, IComparable<Student>
    {
        public enum Courses
        {
            UP,
            OOP,
            SDA
        }
        public enum Specialties
        {
            KN,
            SE,
            IS,
            Informatics
        }
        public enum Universities { SU, TU, UASG, UNSS }
        public enum Faculties { F1, F2, F3, F4 }

        public string FullName { get; set; }
        public int SSN { get; private set; }
        public string Address { get; set; }
        public int PhoneNumber { get; set; }
        public string Email { get; set; }
        public Courses Course { get; set; }
        public Specialties Specialty { get; set; }
        public Universities University { get; set; }
        public Faculties Faculty { get; set; }

        public Student(string fullName, int sSN, string address, 
            int phoneNumber, string email, Courses course, 
            Specialties specialty, Universities university, Faculties faculty)
        {
            this.FullName = fullName;
            this.SSN = sSN;
            this.Address = address;
            this.PhoneNumber = phoneNumber;
            this.Email = email;
            this.Course = course;
            this.Specialty = specialty;
            this.University = university;
            this.Faculty = faculty;
        }

        public override bool Equals(object obj)
        {
            Student other = obj as Student;
            if (other == null)
            {
                return false;
            }
            return 
                this.FullName.Equals(other.FullName) &&
                this.SSN.Equals(other.SSN) &&
                this.Address.Equals(other.Address) &&
                this.PhoneNumber.Equals(other.PhoneNumber) &&
                this.Email.Equals(other.Email) &&
                this.Course.Equals(other.Course) &&
                this.Specialty.Equals(other.Specialty) &&
                this.University.Equals(other.University) &&
                this.Faculty.Equals(other.Faculty);
        }

        public override int GetHashCode()
        {
            return 
                FullName.GetHashCode() ^
                SSN.GetHashCode() ^
                Address.GetHashCode() ^
                PhoneNumber.GetHashCode() ^
                Email.GetHashCode() ^
                Course.GetHashCode() ^
                Specialty.GetHashCode() ^
                University.GetHashCode() ^
                Faculty.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format(
                "{0}, \n{1}, \n{2}, \n{3}, \n{4}, \n{5}, \n{6}, \n{7}, \n{8}",
                FullName, SSN, Address, PhoneNumber, 
                Email, Course, Specialty, University, Faculty);
        }

        public static bool operator == (Student student1, Student student2)
        {
            return student1.Equals(student2);
        }

        public static bool operator !=(Student student1, Student student2)
        {
            return !(student1.Equals(student2));
        }

        public object Clone()
        {
            return new Student(FullName, SSN, Address, PhoneNumber, 
                Email, Course, Specialty, University, Faculty);
        }

        public int CompareTo(Student other)
        {
            int result = this.FullName.CompareTo(other.FullName);
            if (result == 0)
            {
                result = this.SSN.CompareTo(other.SSN);
            }
            return result;
        }
    }
}
